home *** CD-ROM | disk | FTP | other *** search
- /*============================================================
-
- Hit sample program
-
- ============================================================*/
- #include "N_Library.h"
-
- void Main_Loop(void);
-
- short Data_Rsrc = 0;
- long total_step = 0;
- long wait;
- short i,xx,yy,r=0;
- short x[128];
- short y[128];
- float ht[128];
- float m[128];
- float sp[128];
- short vc[128];
- short pat[128];
- Boolean Snd_Flg = false;
- Point mp;
- short col = 0;
- short col_pat[] = {0,0,1,1,2,2,3,3,3,3,2,2,1,1,0,0};
- short sound_list[] = { 9000,0 };
- short rt[128];
-
- void main(void)
- {
- WindowPtr window;
- Rect BGrect;
- short p;
-
- ToolboxInit();
- ColorCheck();
- HideMenuBar();
- window = GetNewWindow (128,nil,(WindowPtr)-1L );
- N_Window_Set(window,-(window->portBits.bounds.left),-(window->portBits.bounds.top),640,480);
- Open_Resource_File(128,1,&Data_Rsrc);
-
- N_Sound_Load(&sound_list[0]);
- N_Sp_Make(640,480);
- N_Cel_Make(350000);
- HideCursor();
- N_Pict_Draw(128,0,0,(GrafPtr)Main_Window,true);
- N_Sprite_Set(129,0,48,48,0,1,1,4); //Sp 0(with rotation)
- N_Sprite_Set(201,80,32,32,0,1,1,0); //Sp 80
- N_Sprite_Set(202,81,32,32,0,1,1,0); //Sp 81
- N_Sprite_Set(130,82,32,32,0,1,1,0); //Sp 82
- N_Sprite_Set(131,83,32,32,0,1,1,0); //Sp 83
- N_Sprite_Set(132,84,32,32,0,1,1,0); //Sp 84
- N_Sprite_Set(133,85,32,32,0,1,1,0); //Sp 85
- N_Sprite_Set(134,86,32,32,0,1,1,0); //Sp 86
- Delay(60,&wait);
- Close_Resource_File(&Data_Rsrc);
-
- for (i=0;i!=128;i++)
- {
- x[i] = GetRandom(0,640-48);
- y[i] = 0;
- ht[i] = GetRandom(0,19);
- m[i] = GetRandom(7,21);
- sp[i] = 0.5;
- pat[i] = 0;
- if (GetRandom(0,1) == 0) vc[i] = 4; else vc[i] = -4;
- }
-
- for (yy=0;yy!=15;yy++)
- {
- for (xx=0;xx!=20;xx++)
- {
- if (GetRandom(0,1)==0)
- N_Sp_Put(0x80000000+80,xx*32,yy*32);
- else N_Sp_Put(0x80000000+81,xx*32,yy*32);
- }
- }
- Begin_Timer_Int(Main_Loop,40);
- do
- {
- }
- while (!Button());
- Stop_Timer_Int();
-
- N_Sound_Close();
- FlushEvents( everyEvent, 0 );
- ColorRevert();
- ShowMenuBar();
- ShowCursor();
- }
-
-
- void Main_Loop(void)
- {
- Boolean flg = false;
- Boolean hit = false;
- unsigned long spr;
-
- for (i=0;i!=16;i++)
- {
- if (m[i]<ht[i])
- {
- sp[i] = -0.8;
- }
- else
- if (-m[i]>ht[i])
- {
- sp[i] = 0.8;
- }
-
- ht[i] = ht[i] + sp[i];
- y[i] = ht[i]*ht[i] + 426 - m[i]*m[i];
- x[i] = x[i] + vc[i];
-
- if (vc[i]>0)
- {
- if (x[i]>=592) vc[i] = -4;
-
- pat[i] = pat[i] + 2;
- if (pat[i] >= 64) pat[i] = 0;
- }
- if (vc[i]<0)
- {
- if (x[i]<=0) vc[i] = 4;
- pat[i] = pat[i] - 2;
- if (pat[i] <= -1) pat[i] = 63;
- }
- spr = 0x80000000 + pat[i];
- N_Cel_Put(i,spr,x[i],y[i]);
-
- flg = N_Cel_Hit2(101,i);
- if (flg == true) hit = true;
- }
- if (hit == false)
- {
- Snd_Flg = false;
- }
-
- if ((hit == true) && (Snd_Flg == false))
- {
- N_Sound_Play(9000);
- Snd_Flg = true;
- }
- col++;
- col = col & 0x0f;
- GetMouse(&mp);
- N_Cel_Put(100,0x80000000+82,mp.h,mp.v);
- N_Cel_Put(101,0x80000000+83+col_pat[col],mp.h,mp.v);
- N_Cel_Loop(0,0);
- }
-
-